from flask_wtf.file import FileField, FileRequired, FileAllowed


def get_admin_upload_txt_form():
    """
    获得登录表单
    :return:
    """
    from flask_wtf import FlaskForm
    from wtforms import StringField, PasswordField, SubmitField
    from wtforms.validators import DataRequired, EqualTo, Length

    class Login(FlaskForm):
        file = FileField(
            label="导入邮件数据",
            validators=[
                # 文件必须选择;
                FileRequired(),
                # 指定文件上传的格式;
                FileAllowed(['txt'], '只接收.txt格式的数据文件')
            ]
        )
        submit = SubmitField(render_kw={
            'value': '导入分发',
            "class": "form-control"
        })

    return Login()
